// /2d
#include<iostream>
#include<cstring>
#include<string>
using namespace std;
const int maxn=100;
int minlen[maxn][maxn];
char a[maxn],b[maxn];
void print(int na,int nb)
{
    if(na<0||nb<0) return;
    if(a[na]==b[nb])
    {
        print(na-1,nb-1);
        cout<<a[na];
    }
    else {
        if(minlen[na-1][nb]+1==minlen[na][nb])
        {
            print(na-1,nb);
            cout<<a[na];
        }
        else if(minlen[na][nb-1]+1==minlen[na][nb])
        {
            print(na,nb-1);
            cout<<b[nb];
        }
    }
}
int main()
{
    cin>>a+1>>b+1;
    int na=strlen(a+1),nb=strlen(b+1);
    for(int i=1;i<=na;i++) minlen[i][0]=i;
    for(int i=1;i<=nb;i++) minlen[0][i]=i;        
    for(int i=1;i<=na;i++)
    {
        for(int j=1;j<=nb;j++)
        {
            if(a[i]==b[j])
            {
                minlen[i][j]=minlen[i-1][j-1]+1;
            }
            else {
                minlen[i][j]=min(minlen[i-1][j],minlen[i][j-1])+1;
            }
        }
    }
    cout<<minlen[na][nb]<<endl;
    print(na,nb);
}